package net.xo68.destiny.starter.worker.handler;

import net.xo68.destiny.contract.domain.job.AbortParameter;
import net.xo68.destiny.contract.domain.job.TriggerParameter;
import net.xo68.destiny.core.timingwheel.process.EventProcessorContext;
import net.xo68.destiny.starter.worker.logger.JobLogger;

/**
 * 任务hander接口
 * @author wuxie
 * @version 2020-10-26
 */
public interface JobHandler {

    /**
     * 设置任务日志
     * @param jobLogger
     */
    void setJobLogger(JobLogger jobLogger);


    /**
     * 执行任务
     * @param processorContext
     * @throws Exception
     */
    void execute(final EventProcessorContext<TriggerParameter> processorContext) throws Exception;

    /**
     * 终止任务
     * @param abortParameter
     * @return
     */
    default boolean abort(final AbortParameter abortParameter){
        return false;
    }
}
